#!/bin/bash
zenity --question --title="Point of no return" --text="This is your only warning. There is no automatic 'uninstaller' if you want to revert the changes you must do so click by click, peck by peck. I hope to write an uninstaller soon.

If you want to continue anyway click 'Ok' otherwise click 'Cancel'."
if [ $? == 1 ]; then
	exit 0
else
(
echo "3" #1
echo "# Please Wait"
#echo "" > .installing
fndone()
{
    rm .installing
    echo "99"
    if [ "$error" == 1 ]; then
	zenity --error --title="Install failed" --text="I have exited on an error. Please see install.log"
	exit
    else
	#Post instructions, applying settings
	echo "# Applying Settings"
	clear
	gconftool-2 --set "/apps/metacity/general/theme" --type string "MidnightBlackPlastic"
	gconftool-2 --set "/desktop/gnome/interface/gtk_theme" --type string "aero-clone"
	gconftool-2 --set "/desktop/gnome/peripherals/mouse/cursor_theme" --type string "aero-drop"
	gconftool-2 --set "/desktop/gnome/interface/icon_theme" --type string "AeroVista"
	gconftool-2 --set "/desktop/gnome/background/picture_filename" --type string "$HOME/Pictures/wallpapers/vista-wallpaper.jpg"
	gconftool-2 --type string --set /desktop/gnome/interface/font_name "Segoe UI 10"
	gconftool-2 --set "/apps/panel/objects/object_0/custom_icon" --type string "/home/"$USER"/.icons/distributor-logo.png"
	#Much thanks to....
	#
	# XpGnome Script
	# Written by PhrankDaChicken
	# http://ubunutu.online02.com/xpgnome
	#
	# Last Update: 1/7/09
	#
	#all of this below was stole from PhrankDaChicken...Phrank you da man! You saved me hours of man pagin'
	# Toolbars - Icons Only
	gconftool-2 --set "/desktop/gnome/interface/toolbar_style" --type string "icons"
	# Nautilus Sidebar
	gconftool-2 --set "/apps/nautilus/preferences/side_pane_view" --type string "NautilusTreeSidebar"
	gconftool-2 --set "/apps/nautilus/sidebar_panels/tree/show_only_directories" --type bool TRUE
	echo "# Creating Panels...."
	## Panel Stuff
	# Create New Panel
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/animation_speed" --type string "medium"
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/auto_hide" --type bool FALSE
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/auto_hide_size" --type int 6
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/enable_animations" --type bool TRUE
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/enable_arrows" --type bool TRUE
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/enable_buttons" --type bool FALSE
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/expand" --type bool TRUE
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/hide_delay" --type int 500
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/monitor" --type int 0
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/name" --type string "bottom_panel_0"
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/orientation" --type string "bottom"
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/screen" --type int 0
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/size" --type int 32
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/unhide_delay" --type int 500 
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/x" --type int 0
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/x_centered" --type bool FALSE
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/x_right" --type int 
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/y" --type int 0
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/y_bottom" --type  int 
	gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/y_centered" --type bool FALSE
	#gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/background/color" --type string "#ffffff"
	#gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/background/fit" --type bool FALSE
	#gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/background/image" --type string ""
	#gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/background/opacity" --type int 6000
	#gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/background/rotate" --type bool FALSE
	#gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/background/stretch" --type bool FALSE
	#gconftool-2 --set "/apps/panel/toplevels/bottom_panel_0/background/type" --type string "gtk"
	# Start Menu
	gconftool-2 --set "/apps/panel/objects/object_0/action_type" --type string "lock"
	gconftool-2 --set "/apps/panel/objects/object_0/attached_toplevel_id" --type string ""
	gconftool-2 --set "/apps/panel/objects/object_0/bonobo_iid" --type string ""
	gconftool-2 --set "/apps/panel/objects/object_0/custom_icon" --type string "/home/"$USER"/.icons/distributor-logo.png"
	gconftool-2 --set "/apps/panel/objects/object_0/launcher_location" --type string ""
	gconftool-2 --set "/apps/panel/objects/object_0/locked" --type bool TRUE
	gconftool-2 --set "/apps/panel/objects/object_0/menu_path" --type string "applications:/"
	gconftool-2 --set "/apps/panel/objects/object_0/object_type" --type string "menu-object"
	gconftool-2 --set "/apps/panel/objects/object_0/panel_right_stick" --type bool FALSE
	gconftool-2 --set "/apps/panel/objects/object_0/position" --type int 0
	gconftool-2 --set "/apps/panel/objects/object_0/tooltip" --type string "Main Menu"
	gconftool-2 --set "/apps/panel/objects/object_0/toplevel_id" --type string "bottom_panel_0"
	gconftool-2 --set "/apps/panel/objects/object_0/use_custom_icon" --type bool TRUE
	gconftool-2 --set "/apps/panel/objects/object_0/use_menu_path" --type bool FALSE
	# Show Desktop
	gconftool-2 --set "/apps/panel/applets/applet_0/action_type" --type string "lock"
	gconftool-2 --set "/apps/panel/applets/applet_0/attached_toplevel_id" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_0/bonobo_iid" --type string "OAFIID:GNOME_ShowDesktopApplet"
	gconftool-2 --set "/apps/panel/applets/applet_0/custom_icon" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_0/launcher_location" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_0/locked" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_0/menu_path" --type string "applications:/"
	gconftool-2 --set "/apps/panel/applets/applet_0/object_type" --type string "bonobo-applet"
	gconftool-2 --set "/apps/panel/applets/applet_0/panel_right_stick" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_0/position" --type int 1
	gconftool-2 --set "/apps/panel/applets/applet_0/tooltip" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_0/toplevel_id" --type string "bottom_panel_0"
	gconftool-2 --set "/apps/panel/applets/applet_0/use_custom_icon" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_0/use_menu_path" --type bool FALSE
	# Window Switcher
	gconftool-2 --set "/apps/panel/applets/applet_1/action_type" --type string "lock"
	gconftool-2 --set "/apps/panel/applets/applet_1/attached_toplevel_id" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_1/bonobo_iid" --type string "OAFIID:GNOME_WindowListApplet"
	gconftool-2 --set "/apps/panel/applets/applet_1/custom_icon" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_1/launcher_location" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_1/locked" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_1/menu_path" --type string "applications:/"
	gconftool-2 --set "/apps/panel/applets/applet_1/object_type" --type string "bonobo-applet"
	gconftool-2 --set "/apps/panel/applets/applet_1/panel_right_stick" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_1/position" --type int 2
	gconftool-2 --set "/apps/panel/applets/applet_1/tooltip" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_1/toplevel_id" --type string "bottom_panel_0"
	gconftool-2 --set "/apps/panel/applets/applet_1/use_custom_icon" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_1/use_menu_path" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_1/prefs/display_all_workspaces" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_1/prefs/group_windows" --type string "never"
	gconftool-2 --set "/apps/panel/applets/applet_1/prefs/maximum_size" --type int 4096
	gconftool-2 --set "/apps/panel/applets/applet_1/prefs/minimum_size" --type int 50
	gconftool-2 --set "/apps/panel/applets/applet_1/prefs/move_unminimized_windows" --type bool TRUE
	# Notification Area
	gconftool-2 --set "/apps/panel/applets/applet_2/action_type" --type string "lock"
	gconftool-2 --set "/apps/panel/applets/applet_2/attached_toplevel_id" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_2/bonobo_iid" --type string "OAFIID:GNOME_NotificationAreaApplet"
	gconftool-2 --set "/apps/panel/applets/applet_2/custom_icon" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_2/launcher_location" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_2/locked" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_2/menu_path" --type string "applications:/"
	gconftool-2 --set "/apps/panel/applets/applet_2/object_type" --type string "bonobo-applet"
	gconftool-2 --set "/apps/panel/applets/applet_2/panel_right_stick" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_2/position" --type int 3
	gconftool-2 --set "/apps/panel/applets/applet_2/tooltip" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_2/toplevel_id" --type string "bottom_panel_0"
	gconftool-2 --set "/apps/panel/applets/applet_2/use_custom_icon" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_2/use_menu_path" --type bool FALSE
	# Volume Control
	gconftool-2 --set "/apps/panel/applets/applet_3/action_type" --type string "lock"
	gconftool-2 --set "/apps/panel/applets/applet_3/attached_toplevel_id" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_3/bonobo_iid" --type string "OAFIID:GNOME_MixerApplet"
	gconftool-2 --set "/apps/panel/applets/applet_3/custom_icon" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_3/launcher_location" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_3/locked" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_3/menu_path" --type string "applications:/"
	gconftool-2 --set "/apps/panel/applets/applet_3/object_type" --type string "bonobo-applet"
	gconftool-2 --set "/apps/panel/applets/applet_3/panel_right_stick" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_3/position" --type int 2
	gconftool-2 --set "/apps/panel/applets/applet_3/tooltip" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_3/toplevel_id" --type string "bottom_panel_0"
	gconftool-2 --set "/apps/panel/applets/applet_3/use_custom_icon" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_3/use_menu_path" --type bool FALSE
	# Clock
	gconftool-2 --set "/apps/panel/applets/applet_4/action_type" --type string "lock"
	gconftool-2 --set "/apps/panel/applets/applet_4/attached_toplevel_id" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_4/bonobo_iid" --type string "OAFIID:GNOME_ClockApplet"
	gconftool-2 --set "/apps/panel/applets/applet_4/custom_icon" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_4/launcher_location" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_4/locked" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_4/menu_path" --type string "applications:/"
	gconftool-2 --set "/apps/panel/applets/applet_4/object_type" --type string "bonobo-applet"
	gconftool-2 --set "/apps/panel/applets/applet_4/panel_right_stick" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_4/position" --type int 0
	gconftool-2 --set "/apps/panel/applets/applet_4/tooltip" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_4/toplevel_id" --type string "bottom_panel_0"
	gconftool-2 --set "/apps/panel/applets/applet_4/use_custom_icon" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/use_menu_path" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/config_tool" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/custom_format" --type string ""
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/expand_appointments" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/expand_birthdays" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/expand_tasks" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/expand_weather" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/format" --type string "12-hour"
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/gmt_time" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/hour_format" --type string "12"
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/internet_time" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/show_date" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/show_seconds" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/show_timezones" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/show_tooltip" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/show_week_numbers" --type bool TRUE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/unix_time" --type bool FALSE
	gconftool-2 --set "/apps/panel/applets/applet_4/prefs/timezones/tz_id_list" --type list --list-type string "[]"
	# Add Panels Items
	gconftool-2 --set "/apps/panel/general/applet_id_list" --type list --list-type string "[applet_0,applet_1,applet_2,applet_3,applet_4]"
	gconftool-2 --set "/apps/panel/general/object_id_list" --type list --list-type string "[object_0]"
	gconftool-2 --set "/apps/panel/general/toplevel_id_list" --type list --list-type string "[bottom_panel_0]"
	# Desktop Icons
	gconftool-2 --set "/apps/nautilus/desktop/computer_icon_visible" --type bool TRUE
	gconftool-2 --set "/apps/nautilus/desktop/computer_icon_name" --type string "My Computer"
	gconftool-2 --set "/apps/nautilus/desktop/home_icon_visible" --type bool TRUE
	gconftool-2 --set "/apps/nautilus/desktop/home_icon_name" --type string "My Documents"
	gconftool-2 --set "/apps/nautilus/desktop/network_icon_visible" --type bool TRUE
	gconftool-2 --set "/apps/nautilus/desktop/network_icon_name" --type string "My Network Places"
	gconftool-2 --set "/apps/nautilus/desktop/trash_icon_visible" --type bool TRUE
	gconftool-2 --set "/apps/nautilus/desktop/trash_icon_name" --type string "Recycle Bin"
	gconftool-2 --set "/apps/nautilus/desktop/volumes_visible" --type bool FALSE
	echo "" >> install.log
	echo "Done." >> install.log
	clear
	echo "100"
	echo "# Now launching post install instructions, click \"Ok\" when finished."
	echo ""
	emerald-theme-manager & sleep 4 && zenity --text-info --title="Post installation tasks" --filename=after-install 
	zenity --info --title "VistaGNOME GDM Setup" --text "After clicking 'OK', select the 'Local' tab in the next window, then select the 'Linux Vista' theme. 

	Note: This will only work in GNOME 2.26 or less (i.e. this doesn't work in Ubuntu 9.10)"
	gksu --message "GDM Setup needs administrative permissions to run" gdmsetup
        cp -rv $PWD/vista/login-theme/zzzrunoncegdmfix.desktop $HOME/.config/autostart/zzzrunoncegdmfix.desktop
        cp -rv $PWD/vista/login-theme/gdmfix.sh $HOME/.gdmfix.sh
	zenity --info --title="Vista Menu(TM)" --text="As of this version the most reliable true Vista(TM) Menu that is available is still quite buggy and therefore we are not including it in this installer script. You can download and install it yourself (its really easy, promise) by going here: http://www.gnome-look.org/content/show.php/vistamenu%28GnoMenu%29?content=95756"
	zenity --info --title="Wallpapers" --text="I have automatically applied a Vista wallpaper. Two came with this package. They are both located in your Pictures folder under 'Wallpapers'"
        zenity --info --title="Login Sound Setup" --text="In the following screen click on the 'sounds' tab and then locate 'login sound' click on the word 'default' beside it and select in the subsequent drop down menu 'custom'. Then select 'vista-startup.wav'.
	
	Note: This will not work on Ubuntu 9.10."
	gnome-sound-properties
	zenity --warning --title="Please Note..." --text="You must log off this GNOME session and login again for the settings to completely apply."
	exit
    fi
}
#don't need this any more since we use zenity. besides, it caused the script to hang..very dirty
#fnwait()
#{
#while [ -f .installing ]; do
#	echo -n "***** . "
#	sleep 1
#done
#}
#fnwait &
if [ -f /usr/bin/emerald ] && [ -f /usr/bin/compiz ]; then
	echo "6" #2
	echo "# Emerald and Compiz already installed"
	echo "Emerald and Compiz already installed, continuing without action" >> install.log
elif [ ! -f /usr/bin/emerald ] && [ -f /usr/bin/compiz ]; then
	echo "6" #2
	echo "# Installing Emerald, Compiz already installed"
	echo "Installing Emerald, Compiz already installed" >> install.log
	gksu --message "I need administrative privileges to install Emerald" echo
	sudo apt-get install -yV emerald >> install.log
elif [ -f /usr/bin/emerald ] && [ ! -f /usr/bin/compiz ]; then
	echo "6" #2
	echo "# Installing Compiz, Emerald already installed"
	echo "Installing Compiz, Emerald already installed...WTF" >> install.log
	gksu --message "I need administrative privileges to install Compiz" echo
	sudo apt-get install -yV compiz >> install.log
elif [ ! -f /usr/bin/emerald ] && [ ! -f /usr/bin/compiz ]; then
	echo "6" #2
	echo "# Installing Compiz and Emerald"
	echo "Installing Compiz and Emerald" >> install.log
	gksu --message "I need administrative privileges to install Compiz and Emerald" echo
	sudo apt-get install -yV compiz emerald >> install.log
else
	exit 1
fi
echo "9" #3
echo `date` > install.log
echo "" >> install.log
echo "12" #4
echo "# Installing icon theme"
echo "" >> install.log
echo "Moving icon theme" >> install.log
echo "" >> install.log
echo "15" #5
if [ -e /home/$USER/.icons ]; then
    echo "/home/"$USER"/.icons already exists" >> install.log
else
    mkdir /home/$USER/.icons
fi
echo "18" #6
cp $PWD/vista/icon-theme/AeroVista/ /home/$USER/.icons/ -Rv >> install.log
echo "21" #7
if [ -e /home/$USER/.icons/AeroVista ]; then
    echo "Done moving icon theme" >> install.log
else
    echo "Moving icon theme failed" >> install.log
    #I don't think this will work as needed need to reset install var first
    error=1
    fndone
fi
#echo "# Setting icon theme"
#echo "Setting icon theme" >> install.log
#gconftool-2 --set "/desktop/gnome/interface/icon_theme" --type string "AeroVista"
echo "# Installing GTK themes"
echo "" >> install.log
echo "Moving GTK themes" >> install.log
echo "" >> install.log
echo  "---------------------Make directory for themes--------------------" >> install.log
if [ -e /home/$USER/.themes ]; then
    echo "Theme directory already exists" >> install.log
else
    mkdir /home/$USER/.themes
fi
echo "24" #8
cp $PWD/vista/gtk-metacity-theme/Vista/ /home/$USER/.themes/ -Rv >> install.log
echo "27" #9
cp $PWD/vista/gtk-metacity-theme/aero-clone/ /home/$USER/.themes/ -Rv >> install.log
echo "30" #10
cp $PWD/vista/gtk-metacity-theme/MidnightBlackPlastic/ /home/$USER/.themes/ -Rv >> install.log
echo "" >> install.log
#check to see if it actually worked
echo "33" #11
if [ -e $HOME/.themes/aero-clone ] && [ -e $HOME/.themes/Vista ] && [ -e $HOME/.themes/MidnightBlackPlastic ]; then
    echo "Done moving GTK theme - Aero Clone and Vista" >> install.log
elif [ ! -e $HOME/.themes/Vista ]; then
    echo "Aero Clone Failed others may have failed as well" >> install.log
    error=1
#    read -p "I will now exit"
    fndone
elif [ ! -e $HOME/.themes/aero-clone ]; then
    echo "Vista theme failed MidnightBlackPlastic may have failed as well" >> install.log
    error=1
#    read -p "I will now exit"
    fndone
elif [ ! -e $HOME/.themes/MidnightBlackPlastic ]; then
    echo "GTK theme MidnightBlackPlastic move failed all others succeeded" >> install.log
    fndone
else
    echo "Successfully moved GTK themes" >> install.log
fi

echo "" >> install.log
echo "36" #12
echo "# Installing Mouse theme"
echo "" >> install.log
echo "Moving mouse cursor theme" >> install.log
echo "" >> install.log
echo "39" #13
cp $PWD/vista/mouse-theme/aero-drop/ /home/$USER/.icons/ -Rv >> install.log
echo "42" #14
if [ -e /home/$USER/.icons/aero-drop ]; then
    echo "Done moving mouse cursor theme" >> install.log
else
    echo "Moving cursor theme failed" >> install.log
    error=1
    read -p "moving cursor theme failed"
    fndone
fi
echo "" >> install.log
#echo "54"
#Commenting out this section since GNOME splash doesn't go with the Vista theme and would require more dependencies
#and set-up and possibly user configuration
#echo "# Installing GNOME splash"
#echo "" >> install.log
#echo "Moving GNOME splash" >> install.log
#echo "" >> install.log
#echo "41"
#if [ -e /home/$USER/.gnome2/splashes ]; then
#    echo "/home/"$USER"/.gnome2/splashes already exists" >> install.log
#else
#    mkdir /home/$USER/.gnome2/splashes/
#fi
#echo "44"
#cp -v $PWD/vista/gnome-splash/vista-splash.png /home/$USER/.gnome2/splashes/ >> install.log
#echo "47"
#if [ -e /home/$USER/.gnome2/splashes/vista-splash.png ]; then
#    echo "Done moving GNOME splash" >> install.log  
#else 
#    echo "Moving GNOME splash failed" >> install.log
#    error=1
#    read -p "Moving GNOME splash failed"
#    fndone
#fi
echo "45" #15
echo "" >> install.log
echo "48" #16
echo "# Installing the Vista(TM) startup sound"
echo "" >> install.log
echo "Moving Vista startup sound" >> install.log
echo "" >> install.log
gksu --message "Vista(TM) theme installer (install.sh) needs root access to install sound" echo
echo "51" #17
sudo cp -v $PWD/vista/sound-theme/vista-startup.wav /usr/share/sounds/ >> install.log
echo "54" #18
if [ -e /usr/share/sounds/vista-startup.wav ]; then
    echo "Done moving Vista startup sound" >> install.log    
else
    echo "Moving vista startup sound failed" >> install.log
    error=1
    read -p "moving vista startup sound failed"
    fndone
fi
echo "57" #19
echo "" >> install.log
echo "60" #20
echo "# Installing GDM login theme"
echo "" >> install.log
echo "Moving GDM Vista login theme" >> install.log
echo "" >> install.log
echo "63" #21
sudo cp $PWD/vista/login-theme/vista-login /usr/share/gdm/themes/ -Rv >> install.log
echo "65" #22
if [ -e /usr/share/gdm/themes/vista-login ]; then
    echo "Done moving GDM login theme" >> install.log    
else
    echo "Moving GDM theme failed" >> install.log
    error=1
    read -p "moving gdm theme failed"
    fndone
fi
echo "" >> install.log
echo "68" #23
echo "# Installing the Emerald Vista(TM) theme"
echo "" >> install.log
echo "Moving the Vista Emerald theme" >> install.log
echo "" >> install.log
echo "71" #24
if [ -e $HOME/.emerald ]; then
	echo $HOME"/.emerald exists" >> install.log
else
	mkdir $HOME/.emerald
fi
echo "74" #25
cp -v $PWD/vista/emerald-theme/aero_blue.emerald /home/$USER/.emerald/ >> install.log
echo "77" #26
if [ -f /home/$USER/.emerald/aero_blue.emerald ]; then
    echo "Done moving Emerald theme" >> install.log
    ln -s $HOME/.emerald $HOME/Emerald-Themes
else
    echo "Moving Emerald theme failed" >> install.log
    error=1
    read -p "Moving emerald theme failed"
    fndone
fi
echo "80" #27
echo "" >> install.log
echo "83" #28
echo "# Installing font"
echo "" >> install.log
echo "Moving Segoe UI font files" >> install.log
echo "" >> install.log
echo "86" #29
if [ -e /home/$USER/.fonts ]; then
    echo "/home/"$USER"/.fonts exists" >> install.log
else
    mkdir /home/$USER/.fonts/
fi
echo "90" #30
cp -v $PWD/vista/font/seg* /home/$USER/.fonts/ >> install.log
echo "93" #33
if [ -f /home/$USER/.fonts/seguibd.ttf ] && [ -f /home/$USER/.fonts/seguibk.ttf ]; then
    echo "Done moving font" >> install.log
elif [ -f /home/$USER/.fonts/seguibd.ttf ]; then
    echo "Only seguibd.ttf was moved" >> install.log
    error=1
    fndone
elif [ -f /home/$USER/.fonts/seguibk.ttf ]; then
    echo "Only seguibk.ttf was moved" >> install.log
    error=1
    fndone
else
    echo "Font moving completely failed" >> install.log
    error=1
    read -p "Font moving completely failed"
    fndone
fi
echo "96" #34
echo "" >> install.log
echo "# Misc Tasks" #we should be careful not to let this section get to messy and undefined
#copying over wallpapers
echo "copying over wallpapers" >> install.log
cp $PWD/vista/wallpapers/ $HOME/Pictures/ -Rv >> install.log
#http://library.gnome.org/devel/autostart-spec/ setting emerald --replace to auto start
echo "setting emerald --replace to run on start" >> install.log
if [ -e $HOME/.config/autostart ]; then
	cp $PWD/vista/emerald-theme/emerald-replace.desktop $HOME/.config/autostart/aaaemerald-replace.desktop -Rv >> install.log
else
	mkdir $HOME/.config/autostart
	cp $PWD/vista/emerald-theme/emerald-replace.desktop $HOME/.config/autostart/aaaemerald-replace.desktop -Rv >> install.log
fi
#copying over the vista logo
echo "copying over the vista logo" >> install.log
cp -Rv $PWD/vista/distributor-logo.png $HOME/.icons/distributor-logo.png >> install.log
#Setting usplash
echo "# Installing Vista Usplash"
echo "setting usplash" >> install.log
gksu --message "I need administrative privileges to change the boot splash" echo
sudo tar xvvzf $PWD/vista/usplash-theme/usplash-theme-vista.tar.gz -C /usr/lib/usplash >> install.log
sudo update-alternatives --install /usr/lib/usplash/usplash-artwork.so usplash-artwork.so /usr/lib/usplash/usplash-theme-vista.so 50 >> install.log
sudo update-alternatives --set usplash-artwork.so /usr/lib/usplash/usplash-theme-vista.so >> install.log
sudo update-initramfs -u >> install.log
error=0
fndone ) |
        zenity --progress \
          --title="Installing Vista(TM) Aero Theme for GNOME" \
          --text="Please Wait..." \
          --percentage=0 \
	  --width=600

        if [ "$?" = -1 ] ; then
                zenity --error \
                  --text="Install Failed, see install.log."
        fi
fi
